package com.xinyue.authorization.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import com.xinyue.authorization.bean.User;
import com.xinyue.authorization.service.UserService;
import commons.ParamHandler;

@Controller
public class UserController {
	@Autowired
	UserService service;

	/**
	 * 
	 */
	@RequestMapping(value="authorization/user/save")
	public ModelAndView save(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mv = new ModelAndView("/page");
		
		try {
			User u = ParamHandler.process(request, User.class);
			service.save(u);
		} catch (Exception e) {
			e.printStackTrace();
		}
		
		return mv;
	}
	
	/**
	 * 
	 */
	@RequestMapping(value="authorization/user/update")
	public ModelAndView update(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mv = new ModelAndView("/page");
		
		try {
			User u = ParamHandler.process(request, User.class);
			service.update(u);
		} catch (Exception e) {
		}
		return mv;
	}
	
	/**
	 * 
	 */
	@RequestMapping(value="authorization/user/delete")
	public ModelAndView delete(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mv = new ModelAndView("/page");
		
		return mv;
	}
	
	/**
	 * 
	 */
	@RequestMapping(value="authorization/user/queryAll")
	public ModelAndView queryAll(HttpServletRequest request, HttpServletResponse response) {
		ModelAndView mv = new ModelAndView("/page");
		return mv;
	}
}
